package com.sskj.gcc.market;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.gcc.market.data.BuySellData;
import com.sskj.gocoin.m.HttpConfig;
import com.sskj.gocoin.m.bean.HttpData;
import com.sskj.gocoin.m.http.JsonCallBack;
import com.sskj.gocoin.p.base.BasePresenter;

import java.util.List;


/**
 * @author Hey
 * Create at  2019/07/31 10:25:20
 */
class DeepthPresenter extends BasePresenter<DepthFragment> {


    public void getDeepData(String code) {
        OkGo.<HttpData<List<BuySellData>>>get(HttpConfig.BASE_URL + HttpConfig.GET_DEEP)
                .params("code", code)
                .params("type", "pct")
                .tag(this)
                .execute(new JsonCallBack<HttpData<List<BuySellData>>>(this) {
                    @Override
                    protected void _onSuccess(Response<HttpData<List<BuySellData>>> response) {
                        if (response.body().getData() != null && response.body().getData().size() > 0) {
                            mView.setDeepMap(response.body().getData().get(0));
                        }
                    }
                });
    }


    /**
     * 获取盘口数据
     * @param code
     */
    public void getPanKouData(String code) {
        OkGo.<HttpData<List<BuySellData>>>get(HttpConfig.BASE_URL + HttpConfig.GETDEPTH)
                .params("code", code)
                .params("type", "depth")
                .tag(this)
                .execute(new JsonCallBack<HttpData<List<BuySellData>>>(this) {
                    @Override
                    public void _onSuccess(Response<HttpData<List<BuySellData>>> response) {
                        if(response.body().getData().size()>0){
                            mView.setDeepOrder(response.body().getData().get(0));
                        }
                    }
                });
    }
}
